<?php

namespace frontend\controllers;



use Yii;
use yii\web\Controller;

use common\models\Dd;
use common\models\Systemconfig;
use common\models\User;


/**
 * 前台基础，全局处理等
 */
class FController extends Controller
{



	public $w_config = [];  //用于Controller 
    public $page = [];  //默认页面标题
    public $user_info = []; //用户信息

	public function init(){
        //加载共用方法
        require_once(Yii::getAlias('@common').'/functions.php');

        $this->w_config = Systemconfig::getConfigValue('website');
        Yii::$app->view->params['w_config'] = $this->w_config;  //用于view,view里面这样使用 $this->params['w_config']

        $this->setPage();   //设置页面标题

        if(Yii::$app->user->isGuest) {
            $this->user_info = [];
        } else {
            $user_info = User::findOne(1);
        }
                
        //echo Yii::$app->user->isGuest;
        //print_r(Yii::$app->user);exit;


	}

    /**
     * 设置页面标题
     */
    public function setPage(){

        $page = Systemconfig::getConfigValue('page');
        if(!isset($page['page_title'])) {
            $page['page_title'] = '';
        }
        if(!isset($page['page_keywords'])) {
            $page['page_keywords'] = '';
        }
        if(!isset($page['page_description'])) {
            $page['page_description'] = '';
        }
        $this->page = $page;
        Yii::$app->view->params['page'] = $this->page;  //用于view,view里面这样使用 $this->params['page']

    }

	//关于属性  http://www.yiichina.com/doc/guide/2.0/concept-properties
    // private $_websiteconfig;
    // public function getWebsiteconfig()
    // {
    // 	$this->_websiteconfig = Systemconfig::getConfigValue('website');
    //     return $this->_websiteconfig;
    // }

    // public function setWebsiteconfig($value)
    // {
    //     $this->_websiteconfig = $value;
    // }

}

